<template>
    <div class="header-container">
        <div class="l-content">
            <el-button icon="el-icon-menu" size="medium" @click="handleMenu"></el-button>
            <el-breadcrumb separator="/" style="padding-left: 20px">
                <el-breadcrumb-item v-for="item in tags" :key="item.path" :to="{ path: item.path }">{{
                    item.label
                }}</el-breadcrumb-item>
            </el-breadcrumb>
        </div>
        <div class="r-content">
            <el-dropdown :hide-on-click="false" @command="handleCommand">
                <span class="el-dropdown-link">
                    <img class="user_image" src="@/assets/images/user.jpg">
                </span>
                <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item command="a">个人信息</el-dropdown-item>
                    <el-dropdown-item command="b">退出</el-dropdown-item>
                </el-dropdown-menu>
            </el-dropdown>
        </div>
    </div>
</template>
<script>
import { mapState } from 'vuex'

export default {
    name: 'Header',
    data() {
        return {}
    },
    methods: {
        handleMenu() {
            // console.log(111)
            //对菜单做缩放操作
            this.$store.commit('collapseChang')
        },
        handleCommand(command) {
            if ('b' === command) {
                this.$confirm('是否要退出?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    sessionStorage.clear();//清空token信息
                    this.$router.push('Login')
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消'
                    });
                });
            }
        }
    }, computed: {
        ...mapState({
            tags: state => state.tab.tabsList
        })
    }
}
</script>
<style lang="less">
.header-container {
    height: 60px;
    background-color: #242f42;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.l-content {
    margin-left: 20px;
    display: flex;
    align-items: center;

    // /deep/
    .el-breadcrumb__item {
        .el-breadcrumb__inner {
            font-weight: normal;

            &.is-link {
                color: #666;
            }
        }

        &:last-child {
            .el-breadcrumb__inner {
                color: #ffffff;
            }
        }
    }
}

.r-content {
    padding-right: 20px;

    .user_image {
        width: 40px;
        height: 40px;
        border-radius: 50%;
    }
}

.firstPage {
    font-size: 16px;
    color: #fff;
    margin-left: 10px;
    cursor: pointer;
}

.el-dropdown-link {
    cursor: pointer;
    color: #409EFF;
}

.el-icon-arrow-down {
    font-size: 12px;
}
</style>